package com.shrct.businessprocess.purchase.impl;

import com.shrct.businessprocess.product.RCProductEntry;
import com.shrct.businessprocess.product.impl.RCProductEntryImpl;
import com.shrct.businessprocess.purchase.RCProductInStockEvent;
import com.shrct.businessprocess.purchase.RCPurchaseOrderItem;
import com.shrct.businessprocess.purchase.impl.RCPurchaseOrderItemImpl;
import com.shrct.businessprocess.purchase.proxy.RCProductInStockEventProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCPRODUCTINSTOCKEVENT_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcproductinstockevent")
public class RCProductInStockEventImpl extends BaseModelObject implements RCProductInStockEvent {
  public RCProductInStockEventImpl() {
    super();
  }
  
  @JoinColumn(name = "orderItem_id")
  @ManyToOne(targetEntity = RCPurchaseOrderItemImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCPurchaseOrderItem orderItem;
  
  public RCPurchaseOrderItem getOrderItem() {
    return this.orderItem;
  }
  
  public RCProductInStockEvent setOrderItem(final RCPurchaseOrderItem orderItem) {
    this.orderItem = orderItem;
    return this;			
    
  }
  
  @JoinColumn(name = "product_id")
  @ManyToOne(targetEntity = RCProductEntryImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCProductEntry product;
  
  public RCProductEntry getProduct() {
    return this.product;
  }
  
  public RCProductInStockEvent setProduct(final RCProductEntry product) {
    this.product = product;
    return this;			
    
  }
  
  private Date date;
  
  public Date getDate() {
    return this.date;
  }
  
  public RCProductInStockEvent setDate(final Date date) {
    this.date = date;
    return this;			
    
  }
  
  private Integer quantity;
  
  public Integer getQuantity() {
    return this.quantity;
  }
  
  public RCProductInStockEvent setQuantity(final Integer quantity) {
    this.quantity = quantity;
    return this;			
    
  }
  
  public static RCProductInStockEvent create(final IObjectFactory objectFactory) {
    com.shrct.businessprocess.purchase.RCProductInStockEvent rCProductInStockEvent = new com.shrct.businessprocess.purchase.impl.RCProductInStockEventImpl(
    );
    objectFactory.create(rCProductInStockEvent);
    return rCProductInStockEvent;			
    
  }
  
  public static RCProductInStockEvent createRCProductInStockEventImpl(final IObjectFactory objectFactory, final Procedure1<RCProductInStockEvent> init) {
    com.shrct.businessprocess.purchase.RCProductInStockEvent rCProductInStockEvent = new com.shrct.businessprocess.purchase.impl.RCProductInStockEventImpl(
    );
    objectFactory.create(rCProductInStockEvent);
    init.apply(rCProductInStockEvent);
    
    return rCProductInStockEvent;			
    
  }
  
  public RCProductInStockEventProxy toProxy() {
    com.shrct.businessprocess.purchase.proxy.RCProductInStockEventProxy proxy = new com.shrct.businessprocess.purchase.proxy.RCProductInStockEventProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
